<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/19/019
 * Time: 20:29
 */

namespace app\lib\Order\OrderMoney;


class EditOrderMoneyRecord extends OrderMoneyRecordBase
{
    /**
     * @return bool
     * @throws \Exception
     */
    public function changePay(){
        $model = $this->getModel();
        $validate = $this->getValidate();
        $data[$model->_status] = 1;
        $data[$model->_paymentTime] = time();
        $data[$model->_paymentId] = $this->paymentId;
        if(!$validate->scene('changePay')->check($data)){
            exception( $validate->getError());
        }
        $map = [$model->_orderMoneyId=>$this->orderMoneyId];
        $result =  $model->where($map)->update($data);
        if(!$result){
            exception('改变交款状态失败');
        }
        return true;
    }
}